package com.example.mvvm.base.livedata;

import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;

/**
 * Time: 5/7/2021 16:27
 * Author: TAO
 * Description:
 */
public class MessageLiveEvent extends SingleLiveEvent<String> {

    public void observe(@NonNull LifecycleOwner owner, @NonNull MessageObserver observer) {
        super.observe(owner, s -> {
            if (s.isEmpty()) {
                return;
            }
            observer.onNewMessage(s);
        });
    }

    public interface MessageObserver {
        void onNewMessage(@NonNull String message);
    }
}
